<!DOCTYPE html>
<html lang="en">
<meta name="x-csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="/css/app.css">
<body>
<h1>登陆</h1>
<form action="{{url('/login')}}" method="post">
    <input type="hidden" name="_token" value="{{csrf_token()}}" id="token"/>
    用户名:<input type="text" name="username" id="username">
    密码:<input type="password" name="pwd" id="pwd">
    <input type="submit" id="send" value="登陆">
</form>
<script src="https://cdn.staticfile.org/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-validate/1.19.0/jquery.validate.min.js"></script>
<script>
    $.ajaxSetup({
        headers : {
            'X-CSRF-TOKEN' : $("meta[name='x-csrf-token']").attr('content')
        }
    });

    $('#send').click(function () {
        var username = $('#username').val();
        var pwd = $('#pwd').val();
        var token = $('#token').val();
        var data = {username:username,pwd:pwd,__token:token}
            $.post("{{url('/login')}}",data, function (e) {
                if(e.code){
                    window.location.href ="{{url("/show/show")}}";
                }else{
                    alert(e.info);
                }
            });
    });
</script>

</body>
</html>